package com.sale24h.data.adapter;

import java.util.List;

import com.example.sale24h.R;
import com.sale24h.data.clsMatHang;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MathangAdapter extends ArrayAdapter<clsMatHang>
{
	private Context context;
	private List<clsMatHang> lstMatHangs;

	public MathangAdapter(Context context, int resource, List<clsMatHang> objects)
	{	
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
		this.context=context;
		this.lstMatHangs=objects;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater)this.context
		        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rootView=inflater.inflate(R.layout.grid_mathang_item_layout, parent,false);
		
		ImageView imgIcon=(ImageView)rootView.findViewById(R.id.imgIcon);
		TextView tbxMonAn_ten=(TextView)rootView.findViewById(R.id.tbxMonAn_ten);
		clsMatHang matHang=lstMatHangs.get(position);
		tbxMonAn_ten.setText(matHang.getTenHang());
		rootView.setTag(matHang);
		return rootView;
	}
	

}
